﻿using Microsoft.AspNetCore.SignalR.Client;
using Prism.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Wpf.Netdisk.Extensions;

namespace Wpf.Netdisk.Views
{
    /// <summary>
    /// MainView.xaml 的交互逻辑
    /// </summary>
    public partial class MainView : Window
    {
        //public  string Name = $"监工{new Random().Next(1, 9999999)}号";
        //HubConnection connection;

        public MainView(IEventAggregator eventAggregator)
        {
            InitializeComponent();
            //connection = new HubConnectionBuilder()
            //    .WithUrl("http://localhost:5610/Chat")
            //    .WithAutomaticReconnect()
            //    .Build();
            //Start();
            ////connection.On<string>("online", (msg) =>
            ////{
            ////    this.Dispatcher.Invoke(() =>
            ////    {
            ////        text.Text += msg + "\r\n";
            ////    });
            ////});
            //connection.On<object>("UpdateDownloadProgress", (msg) =>
            //{
            //    this.Dispatcher.Invoke(() =>
            //    {
            //        remsg.Text +="下载进度为:"+  msg+"%" + "\r\n";
            //    });
            //});
            
            this.grid.MouseLeftButtonDown += (o, e) => { DragMove(); };
            eventAggregator.ResgisterMessage(arg =>
            {
                Snackbar.MessageQueue.Enqueue(arg.Message);
            });
        }
        //private async void Start()
        //{
        //    await connection.StartAsync();
        //}
        ///// <summary>
        ///// 进入
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //private  void Button_Click(object sender, RoutedEventArgs e)
        //{ 
        //    //UpdateDownloadProgress
        //    connection.InvokeAsync("UpdateDownloadProgress", "D:\\study\\test", "https://rookie-1309848952.cos.ap-shanghai.myqcloud.com/384e4c1a2b824ec38adb780c79848176-1117787.png");
        //    //
        //    //
        //}
        ///// <summary>
        ///// 退出
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //private  void Button_Click_1(object sender, RoutedEventArgs e)
        //{
        //    connection.InvokeAsync("SignOut", Name);
        //    connection.StopAsync();
        //    this.Close();
        //}
        ///// <summary>
        ///// 发送
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //private void sendClick(object sender, RoutedEventArgs e)
        //{
        //    //sendText
        //    //connection.InvokeAsync("SendMessage",  Name, sendText.Text ); 
        //}
    }
}
